﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DispatchAssist.AppHost
{
    public partial class DelegateMessageShow : Form
    {

        private Service.AlertMessageGetterService service = new Service.AlertMessageGetterService();

        public DelegateMessageShow()
        {
            InitializeComponent();
        }

        public DelegateMessageShow(string Message, bool BtnConfirmVisible, string BtnConfimText,object Tag, bool BtnCancelVisible, string BtnCancelText,bool BtnOkVisible,string BtnOkText)
        {
            InitializeComponent();

            lblMsg.Text = Message;

            btnConfirm.Text = BtnConfimText;
            btnConfirm.Visible = BtnConfirmVisible;
            btnConfirm.Tag = Tag;

            btnCancle.Text = BtnCancelText;
            btnCancle.Visible = BtnCancelVisible;

            btnOK.Text = BtnOkText;
            btnOK.Visible = BtnOkVisible;

        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                service.UpdateDelegateStatus((Guid)btnConfirm.Tag, 1);

                if (DialogResult.OK == MessageBox.Show("你已同意对方的委托申请,当对方退出系统后,对方席位的预警席位会发送到本席位"))
                {
                    this.Close();
                }
            }
            catch
            {
                MessageBox.Show("更新数据失败");
            }
            //this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            try
            {
                service.UpdateDelegateStatus((Guid)btnConfirm.Tag, 2);
                this.Close();
            }
            catch
            {
                MessageBox.Show("更新数据失败");
            }
           
        }

    }
}
